<!DOCTYPE html>
<html lang="zh">

<head>
  <meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
  <meta name="viewport"
    content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no, viewport-fit=cover" />
  <meta content="yes" name="apple-mobile-web-app-capable" />
  <meta content="telephone=no" name="format-detection" />

  <title>苏州同济医院_同济官网在线预约</title>
  <script src="https://xcx.sztjyy.cn/gh/js/vue@2.6.11.js"></script>
  <link rel="stylesheet" href="https://xcx.sztjyy.cn/gh/js/element-ui.css" />
  <script src="https://xcx.sztjyy.cn/gh/js/element-ui.js"></script>
  <link href="https://xcx.sztjyy.cn/gh/layout.css" rel="stylesheet" type="text/css" />
</head>

<body>
  <style>
    [v-cloak] {
      display: none;
    }

    .detailed {
      display: none;
    }
  </style>
  <div id="app" v-cloak>
    <div class="zjban">
      <el-image :src="'https://xcx.sztjyy.cn/gh/zjimg/' + this.zj + '.jpg'" :onerror="defaultImg"></el-image>
    </div>
    <div class="detailed">
      <h5><img src="https://xcx.sztjyy.cn/gh/images/d1.png" alt="">专业擅长</h5>
      <p>{{content.skilled}}</p>
      <h5><img src="https://xcx.sztjyy.cn/gh/images/d2.png" alt="">学术领域</h5>
      <p><span class="more" :class=" ellipsis ? '' : 'ellipsis' " v-if="cLength >= maxLength" @click="doEllipsis()"><img
            class="ro" src="https://xcx.sztjyy.cn/gh/images/arr.png" alt=">"></span>
        {{contentShow}}
      </p>
    </div>
    <el-form class="bd" label-position="right">
      <el-form-item label="">
        <el-input id="tj_name" v-model="name" placeholder="请输入您的姓名"></el-input>
      </el-form-item>
      <el-form-item label="">
        <el-input id="tj_tel" type="number" v-model="tel" minlength="7" placeholder="请输入您的电话号码"></el-input>
      </el-form-item>
      <p class="bd-keshi" v-if="zjList[this.zj]">
        {{zjList[this.zj][1]}}
      </p>
      <input v-if="zjList[this.zj]" type="hidden" id="tj_keshi" :value="zjList[this.zj][1]" />
      <ul class="visit-date">
        <template v-for="(item,index) in zzTime">
          <li v-if="currentDate(item[0],item[1])" @click="changeIndex(index,item[0])"
            :class="{active:currentIndex===index}">
            {{ toDay(item[0])}}<br />
            {{ weekDay(item[0]) }} {{item[1]}}
          </li>
          <li v-else style="background-color: #dcdcdc;">
            {{ toDay(item[0])}}<br />
            {{ weekDay(item[0]) }} {{item[1]}}
          </li>
        </template>
      </ul>
      <template v-for="(date,index) in zzTime">
        <p v-if="currentIndex===index">
          挂号日期：<span v-if="time == ''" style="color: #aaa;">请点击选择挂号日期</span>
          <span v-else>{{time}}</span>
        </p>
      </template>
      <el-form-item label="" style="display: none;">
        <el-input id="time" readonly placeholder="请选择预约日期" suffix-icon="el-icon-date" v-model="time"
          @focus="dialogVisible = true">
        </el-input>
      </el-form-item>
      <el-form-item label="" class="sele-zj">
        <el-select id="doctor" v-model="this.zj" placeholder="请选择专家" @change="onChange($event)">
          <el-option disabled value="">请选择专家</el-option>
          <el-option v-for="(value, name) in zjList" :key="name" :label="value[0]" :value="name">
          </el-option>
        </el-select>
      </el-form-item>
      <input type="hidden" name="tag" id="tag" v-model="tag" />
      <p class="bd-p">
        <span class="bd-p-1"><img src="./images/d3.png" alt="">出诊地点：苏州同济医院</span>
        <span><img class="bd-p-2" src="./images/lock.png" alt="" />隐私保护</span>
      </p>
      <el-row type="flex" justify="space-around">
        <input type="button" value="提交挂号" class="submit-form" @click="submitForm()" />
      </el-row>
    </el-form>

  </div>
  <div class="bottom">
    <a class="home" href="/gh/list_xcx.html">
      <img src="./images/home.png" alt=""> 首 页</a>
    <a class="tx" href="/gh/list_xcx.html">
      <img src="./images/tx.png" alt=""> 特需专家号</a>
    <a class="pt" href="/gh/list.html">
      <img src="./images/pt.png" alt=""> 专科专诊号</a>
  </div>
  <script src="https://xcx.sztjyy.cn/gh/js/jquery.min.js"></script>
  <script src="https://xcx.sztjyy.cn/gh/js/rem.js"></script>
  <!-- 专家列表 -->
  <script src="https://xcx.sztjyy.cn/gh/js/zj.js"></script>
  <script src="https://xcx.sztjyy.cn/gh/js/zjList.js"></script>
  <script src="https://xcx.sztjyy.cn/gh/js/ghApi.js"></script>

  <script>
    var app = new Vue({
      el: '#app',
      data: {
        defaultImg: 'this.src="img/default.jpg"', //默认图
        zj: 'default',
        zjList: zjList,  //医生列表
        name: '',        //姓名
        tel: '',         //电话
        time: '',        //预约日期
        url: document.location.href,
        currentIndex: 0, //选中的日期
        content: {},
        contentShow: '', // 真实显示的内容
        cLength: 0,      // 学术内容长度
        maxLength: 86,   // 收起时最大显示文字长度
        ellipsis: true,  // 是否收缩
        tag: '',   //小程序标签
        zzTime: []  //专家出诊时间
      },
      mounted: function () {
        var url = window.location.href
        var dz_url = url.split('#')[0] //获取#之前的字符串
        var cs = dz_url.split('?')[1] //获取?之后的参数字符串
        if (cs) {
          var cs_arr = cs.split('&') //参数字符串分割为数组
          var cs = {}
          for (var i = 0; i < cs_arr.length; i++) {
            //遍历数组，拿到json对象
            cs[cs_arr[i].split('=')[0]] = cs_arr[i].split('=')[1]
          }
          this.zj = cs.zj
          this.tag = cs.tag
          $('.home').attr("href", "/gh/list_xcx.html?tag=" + cs.tag)
          $('.pt').attr("href", "/gh/list.html?tag=" + cs.tag)
          $('.tx').attr("href", "/gh/list_xcx.html?tag=" + cs.tag)
        } else { cs = {} }

        var maxLength = this.maxLength;
        for (var j = 0; j < profile.length; j++) {
          if (profile[j].pinyin == cs.zj) {
            var contentShow = profile[j].profile;
            contentShow = (contentShow.length > maxLength && this.ellipsis) ? contentShow.substring(0, maxLength - 3) : contentShow;
            this.content = profile[j]
            this.contentShow = contentShow
            this.cLength = this.content.profile.length

            if (!profile[j].id) {
              this.alertMsg('当前专家已无可挂号日期，请选择其他专家！')
            } else {
              this.getAMonth(profile[j].id)
            }
          }
        }
        $('.detailed ').show()
      },
      methods: {
        getAMonth: function (docID) {
          var _this = this
          var d = new Date();
          var todayDate = d.getFullYear() + "-" + (d.getMonth() + 1) + "-" + d.getDate();
          d.setMonth(d.getMonth() + 1)
          var nextMonth = d.getFullYear() + "-" + (d.getMonth() + 1) + "-" + d.getDate();

          $.ajax({
            url: "https://xcx.sztjyy.cn/api/php/index.php/Apiinfo/Tjyy/getDoctorWorkInfoOne/doctor_id/" + docID + "/start/" + todayDate + "/end/" + nextMonth,
            success: function (res) {
              var data = JSON.parse(res)
              if (!data) {
                _this.alertMsg('获取专家信息失败！')
              } else {
                for (var i = 0; i < 30; i++) {
                  var day = new Date(new Date()
                    .setDate(new Date().getDate() + i))
                  var aM = day.getMonth() + 1
                  aM < 10 ? aM = "0" + aM : aM;
                  var aD = day.getDate()
                  aD < 10 ? aD = "0" + aD : aD;
                  var aDate = day.getFullYear() + "-" + aM + "-" + aD

                  //有排班的日期传入zzTime
                  if (data[aDate]) {
                    _this.zzTime.push([aDate, data[aDate]])
                  }
                }
                //无可挂日期时提醒
                if (_this.zzTime == "") {
                  _this.alertMsg('当前专家已无可挂号日期，请选择其他专家！')
                } else {
                  //默认选中第一个日期
                  if (_this.currentDate(_this.zzTime[0][0], _this.zzTime[0][1])) {
                    _this.time = _this.zzTime[0][0]
                  } else {
                    _this.currentIndex = 1
                    _this.time = _this.zzTime[1][0]
                  }
                }
              }
            }
          })
        },
        //对比当前时间是否超过日期
        currentDate: function (date, apm) {
          var today = new Date();
          var time = date.split("-");
          var myDate = new Date(time[0], time[1] - 1, time[2]);
          //上午时间分割至11点
          if (apm == '上午') {
            myDate = myDate.setHours(11);
          } else {
            myDate = myDate.setHours(17);
          }
          if (myDate > today) {
            return true
          } else { return false }
        },
        weekDay: function (day) {
          var weekDay = ['周日', '周一', '周二', '周三', '周四', '周五', '周六']
          var myDate = new Date(Date.parse(day.replace(/-/g, '/')))
          return weekDay[myDate.getDay()]
        },
        toDay: function (day) {
          if (day) {
            var dateArr = day.split('-')
            return dateArr[1] + '月' + dateArr[2] + '日'
          }
        },
        changeIndex: function (index, date) {
          this.currentIndex = index
          this.time = date
        },
        doEllipsis: function () {
          var ellipsis = !this.ellipsis;
          var contentShow = this.content.profile
          var maxLength = this.maxLength;
          // 如果内容长度少于10，则不截取;否则处于收起状态，截取7个文字并加上省略号
          contentShow = (contentShow.length > maxLength && ellipsis) ? contentShow.substring(0, maxLength - 3) : contentShow;
          this.contentShow = contentShow
          this.ellipsis = ellipsis

        },
        alertMsg: function (msg) {
          this.$message({
            message: msg,
            type: 'warning',
            showClose: true,
            offset: 180
          });
        },
        submitForm: function () {
          //姓名
          var uname = this.name
          if (uname == '') {
            $('#tj_name').focus()
            this.alertMsg('请输入您的姓名!')
            return false
          }
          //预约手机
          var uphone = this.tel
          if (uphone != '') {
            if (/^1[3456789]\d{9}$/.test(uphone) == false) {
              this.alertMsg('请输入您的正确联系方式！')
              return false
            }
          } else {
            $('#tj_tel').focus()
            this.alertMsg('请输入联系方式！')
            return false
          }
          //预约时间
          var yyday = this.time
          if (yyday == '') {
            this.alertMsg('请选择预约时间！')
            return false
          }
          var myData = {
            uname: uname, uphone: uphone, yyday: yyday,
            yyks: this.zjList[this.zj][1],
            yyys: zjList[this.zj][0]
          }
          var that = this;
          $.ajaxGuahao(myData,
            function (data) {//成功
              console.log(data)
              that.$message({ message: '提示：预约信息提交成功！咨询员会尽快为您服务！', type: 'success' });
              window.location.href = "https://xcx.sztjyy.cn/wx/index.html"
            }, function (data) {//失败
              console.log(data)
              that.$message({ message: '提示：预约信息提交失败！请联系客服！', type: 'warning' });
            })
          return true;
        }
      },
    })
  </script>
</body>

</html>